<?php

/**
 * JPhpMailer class file.
 *
 * @version alpha 2 (2010-6-3 16:42)
 * @author jerry2801 <jerry2801@gmail.com>
 * @required PHPMailer v5.1
 *
 * A typical usage of JPhpMailer is as follows:
 * <pre>
 * Yii::import('ext.phpmailer.JPhpMailer');
 * $mail=new JPhpMailer;
 * $mail->IsSMTP();
 * $mail->Host='smpt.163.com';
 * $mail->SMTPAuth=true;
 * $mail->Username='yourname@yourdomain';
 * $mail->Password='yourpassword';
 * $mail->SetFrom('name@yourdomain.com','First Last');
 * $mail->Subject='PHPMailer Test Subject via smtp, basic with authentication';
 * $mail->AltBody='To view the message, please use an HTML compatible email viewer!';
 * $mail->MsgHTML('<h1>JUST A TEST!</h1>');
 * $mail->AddAddress('whoto@otherdomain.com','John Doe');
 * $mail->Send();
 * </pre>
 */

require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'class.phpmailer.php';

class JPhpMailer extends PHPMailer
{
	/**
	 * 
	 * @param unknown_type $Subject 标题
	 * @param unknown_type $MsgHTML 正文
	 * @param unknown_type $toEmail 收件人邮箱
	 * @param unknown_type $toName 收件人名称
	 */
	public function sendEmail($Subject,$MsgHTML,$toEmail,$toName='unknow',$retoArr){
		$this->IsSMTP();
		$this->Host = 'smtp.163.com';
		$this->SMTPAuth = true;
		$this->Username = 'huaxiatest@163.com';
		$this->Password = '111111';
		$this->SetFrom('huaxiatest@163.com', 'huaxiatest');
		$this->Subject = $Subject;
		$this->AltBody = '请使用html格式查看。';
		$this->MsgHTML($MsgHTML);
		$this->AddAddress($toEmail, $toName);
		if(count($retoArr)){
			foreach($retoArr as $v){
				$this->AddReplyTo($v['email'],$v['name']);
			}
		}
		return $this->Send();		
	}
}